package io.renren.common.utils;

import com.alibaba.fastjson.JSONObject;

public class Base64Object {

	/**
     * 把base64的String码转换成正常显示的字符串
     */
    public static String base64ToString(String base64) {
        byte[] decode = Base64Util.decode(base64);
        String s = new String(decode);
        return s;
    }
    /**
     * 把String的转换成base64码
     */
    public static String stringToBase64(String ss) {
        byte[] bytes = ss.getBytes();
        String encode = Base64Util.encode(bytes);
        return encode;
    }

    public static void main(String[] args) {
    	JSONObject json = new JSONObject();
    	json.put("username", "桂朝");
    	json.put("password", "123456");
		String tt = json.toJSONString();
		
		String re1 = Base64Object.stringToBase64(tt);
		System.out.println(re1);
		
		System.out.println(Base64Object.base64ToString(re1));
	}
}
